package com.supplychain.scm.core.rocketmq.callback;

import com.supplychain.scm.core.rocketmq.exception.MqSendMsgException;
import lombok.extern.slf4j.Slf4j;
import org.apache.rocketmq.client.producer.SendCallback;
import org.apache.rocketmq.client.producer.SendResult;

/**
 * @Description
 * @Author qiaoqiaoli
 * @Date 2022/6/23 9:34
 */
@Slf4j
public class DefaultMqSendCallback implements SendCallback {

	@Override
	public void onSuccess(SendResult sendResult) {
		log.info("rocketMQ send async message success, [" + sendResult + "]");
	}

	@Override
	public void onException(Throwable e) {
		//报错，直接抛异常带上报错信息
		log.error("rocketMQ send async message fail, [" + e.getMessage() + "]");
		throw new MqSendMsgException(e.getMessage());
	}
}
